fix: keep paragraphs joined across indented line comments - #17
Conversation
Generalize the Space-node guard from #9: when the next Space starts with a newline and the paragraph buffer already ends in a newline plus optional indent, drop the trailing indent and the duplicate newline. This prevents whitespace-only lines in the output, which Typst treats as paragraph breaks. Closes #16
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe parser now joins lines around indented comments for all supported Typst newline forms. It preserves indentation trimming and avoids false paragraph breaks. Parser and integration tests cover the behavior. ChangesParagraph reconstruction
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized parser fix preserves paragraph breaks while preventing indented comments from creating unintended breaks, with passing tests and checks; no actionable merge-blocking risk remains. Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/parse.rs`:
- Around line 79-91: Update the newline handling in the joined logic of the
paragraph parser to recognize every Typst newline form using
typst_syntax::is_newline, including treating CRLF as a single sequence before
removing the prefix. Preserve the existing paragraph joining behavior while
preventing retained indentation and duplicate newlines, and add regression
coverage for each supported newline form.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f03f05bb-7ef1-48a1-8efa-3230f286ae7f
📒 Files selected for processing (2)
src/parse.rstests/integration.rs
Summary
Follow-up to #9, closes #16.
An indented line comment between two sentences still split the paragraph in the diff output: the reconstructed source kept a whitespace-only line (the comment's indent), and Typst treats such lines as paragraph breaks.
Fix
Generalize the Space-node guard from #9. The old guard only skipped a
Spacewhose text was exactly"\n"when the buffer ended with'\n'. Now, when aSpacestarts with a newline and the buffer already ends in a newline plus optional spaces/tabs (the dropped comment's indent), the indent is truncated and the duplicate newline skipped, so no blank or whitespace-only line can appear.The invariant from #9 still holds: bare blank lines are always a single
Parbreaktoken, so two Space nodes spanning a newline can only arise from a dropped comment between them — intentional paragraph breaks are unaffected.Tests
cargo fmt --checkandclippy -D warningsare clean.Summary by CodeRabbit